package com.sgb.member.weight.threefliter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.member.BR;
import com.sgb.member.R;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.view.selection.CommonPopEntity;

import java.util.List;

public class MPickFilterWindowAdapter extends BaseRecycleAdapter<CommonPopEntity> {

    private boolean flag = true;

    public MPickFilterWindowAdapter(Context context, int layout, List<CommonPopEntity> data) {
        super(context, layout, data);
    }

    @Override
    public void convert(ItemViewHolder holder, CommonPopEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView picker = holder.itemView.findViewById(R.id.tv_selected);
        TextView tvName = holder.itemView.findViewById(R.id.tv_select_content);
        if (flag) {
            picker.setVisibility(View.VISIBLE);
            if (holder.getItem().isSelected()) {
                tvName.getPaint().setFakeBoldText(true);
            } else {
                tvName.getPaint().setFakeBoldText(false);
            }
        } else {
            picker.setVisibility(View.GONE);
        }
    }

    @SuppressLint("NotifyDataSetChanged")
    public void setIsDisplay(boolean isDisplay) {
        this.flag = isDisplay;
        notifyDataSetChanged();
    }
}
